package com.robot.system.controller;

import com.robot.system.domain.entity.SysUser;
import com.robot.system.service.ISysUserService;
import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.JedisPool;

/**
 * @Description:TODO
 * @author:qzg
 * @Date:2020-12-04 12:56
 */
@RestController
@AllArgsConstructor
@RequestMapping("")
public class TestController {

    private ISysUserService sysUserService;
    private RedisTemplate redisTemplate;
    private BCryptPasswordEncoder bCryptPasswordEncoder;

    @GetMapping("/register")
    public void register(){
        System.out.println("2462311");
        //redisTemplate.opsForValue().set(RandomUtil.randomUUID(),"111111111111111111");
    }

    @GetMapping("/register2")
    public void register2(){
        System.out.println("fsfsdf");
        //redisTemplate.opsForValue().set(RandomUtil.randomUUID(),"111111111111111111");
    }

    @GetMapping("/register3")
    public void register3(){
        System.out.println("jjjjjj");
        //redisTemplate.opsForValue().set(RandomUtil.randomUUID(),"111111111111111111");
    }

    @PostMapping("/register1")
    public boolean registerUser(@RequestBody SysUser sysUser){
        // 记得注册的时候把密码加密一下
        sysUser.setPassword(bCryptPasswordEncoder.encode(sysUser.getPassword()));
        return sysUserService.save(sysUser);
    }
}
